/**
 * mbaobao.com Inc.
 * Copyright (c) 2011 All Rights Reserved.
 */
package com.peigen.web.depreciate.depreciate.dal.ibatis;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.peigen.web.depreciate.depreciate.dal.daointerface.DepreciateProductChangeLogDAO;


// auto generated imports
import com.peigen.web.depreciate.depreciate.dal.dataobject.DepreciateProductChangeLogDO;
import org.springframework.dao.DataAccessException;
import java.util.List;

/**
 * An ibatis based implementation of dao interface <tt>com.peigen.web.depreciate.depreciate.dal.daointerface.DepreciateProductChangeLogDAO</tt>.
 *
 * This file is generated by <tt>depreciate-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>paygw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/biz/dal/src/conf/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/depreciate_product_change_log.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>depreciate-dalgen</tt> 
 * to generate this file.
 *
 * @author peigen
 */ 
@SuppressWarnings("unchecked")

public class IbatisDepreciateProductChangeLogDAO extends SqlMapClientDaoSupport implements DepreciateProductChangeLogDAO {
	/**
	 *  Insert one <tt>DepreciateProductChangeLogDO</tt> object to DB table <tt>depreciate_product_change_log</tt>, return primary key
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>insert into depreciate_product_change_log(product_id,product_current_price,product_change_price) values (?, ?, ?)</tt>
	 *
	 *	@param depreciateProductChangeLog
	 *	@return long
	 *	@throws DataAccessException
	 */	 
    public long insert(DepreciateProductChangeLogDO depreciateProductChangeLog) throws DataAccessException {
    	if (depreciateProductChangeLog == null) {
    		throw new IllegalArgumentException("Can't insert a null data object into db.");
    	}
    	
        getSqlMapClientTemplate().insert("MS-DEPRECIATE-PRODUCT-CHANGE-LOG-INSERT", depreciateProductChangeLog);

        return depreciateProductChangeLog.getId();
    }

	/**
	 *  Query DB table <tt>depreciate_product_change_log</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, product_id, product_current_price, product_change_price raw_add_time from depreciate_product_change_log where (id = ?)</tt>
	 *
	 *	@param id
	 *	@return DepreciateProductChangeLogDO
	 *	@throws DataAccessException
	 */	 
    public DepreciateProductChangeLogDO findById(long id) throws DataAccessException {
        Long param = new Long(id);

        return (DepreciateProductChangeLogDO) getSqlMapClientTemplate().queryForObject("MS-DEPRECIATE-PRODUCT-CHANGE-LOG-FIND-BY-ID", param);

    }

	/**
	 *  Query DB table <tt>depreciate_product_change_log</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, product_id, product_current_price, product_change_price raw_add_time from depreciate_product_change_log where (product_id = ?)</tt>
	 *
	 *	@param productId
	 *	@return List<DepreciateProductChangeLogDO>
	 *	@throws DataAccessException
	 */	 
    public List<DepreciateProductChangeLogDO> findByProductId(String productId) throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-DEPRECIATE-PRODUCT-CHANGE-LOG-FIND-BY-PRODUCT-ID", productId);

    }

	/**
	 *  Delete records from DB table <tt>depreciate_product_change_log</tt>.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>delete from depreciate_product_change_log where (product_id = ?)</tt>
	 *
	 *	@param productId
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int deleteByProductIdForTest(String productId) throws DataAccessException {

        return getSqlMapClientTemplate().delete("MS-DEPRECIATE-PRODUCT-CHANGE-LOG-DELETE-BY-PRODUCT-ID-FOR-TEST", productId);
    }

}